﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Classes.actions {
    import flash.display.*;
    import Classes.*;

    public class ActionPlayAnimationOneLoop extends ActionPlayAnimation {

        public static const FAILURE_TIME:Number = 0;

        protected var m_timeCalculationFinished:Boolean = false;

        public function ActionPlayAnimationOneLoop(_arg1:NPC, _arg2:String){
            super(_arg1, _arg2, (60 * 1000));
        }
        override public function update(_arg1:Number):void{
            var _local2:NPC;
            var _local3:ItemImageInstance;
            super.update(_arg1);
            if (!this.m_timeCalculationFinished){
                _local2 = (m_mapResource as NPC);
                _local3 = _local2.getItem().getCachedImage(m_animation, _local2, _local2.getDirection());
                if (_local3 == null){
                    return;
                };
                this.m_actionTime = this.extractTime((_local3.image as CompositeItemImage));
                this.m_timeCalculationFinished = true;
            };
        }
        protected function extractTime(_arg1):Number{
            var _local2:AnimatedBitmapRoundRobbin;
            var _local3:CompositeItemImage;
            var _local4:int;
            var _local5:DisplayObject;
            var _local6:Number;
            if ((_arg1 is AnimatedBitmapRoundRobbin)){
                _local2 = (_arg1 as AnimatedBitmapRoundRobbin);
                return ((_local2.frameDelay * (_local2.numFrames - _local2.currentFrame)));
            };
            if ((_arg1 is CompositeItemImage)){
                _local3 = (_arg1 as CompositeItemImage);
                _local4 = 0;
                while (_local4 < _local3.numChildren) {
                    _local5 = _local3.getChildAt(_local4);
                    _local6 = this.extractTime(_local5);
                    if (_local6 != FAILURE_TIME){
                        return (_local6);
                    };
                    _local4++;
                };
            };
            return (FAILURE_TIME);
        }
        override public function exit():void{
            super.exit();
        }

    }
}//package Classes.actions 
